package my.study.java.util.List;

import java.util.ArrayList;
import java.util.List;

public class Main {
	private static long start;
	private static long end;

	private static void start() {
		start = System.currentTimeMillis();
	}

	private static void end() {
		end = System.currentTimeMillis();
		pl(end - start + "ms");
		start = end;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		List<Integer> list = new ArrayList<Integer>();
		test(list);
//		list = new LinkedList<Integer>();
//		test(list);
		Runtime r = Runtime.getRuntime();  
		pl(r.freeMemory());
		pl(r.maxMemory());
		pl(r.totalMemory());

	}

	private static void test(List<Integer> list) {
		int size = 10000000;
		ListImpl impl = new ListImpl(list);
		start();
		impl.insert(size);
		end();
		pl("delete 1:");
		impl.delete(1);
		end();
		impl.delete(1);
		end();
		impl.delete(1);
		end();
		pl("delete 500:");
		impl.delete(size / 2);
		end();
		impl.delete(size / 2);
		end();
		impl.delete(size / 2);
		end();
		pl("delete 999000:");
		impl.delete(size - 100);
		end();
		impl.delete(size - 100);
		end();
		impl.delete(size - 100);
		end();
	}
	public static void pl(Object o) {
		System.out.println(o);
	}

}
